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1, 1, 1, 1, 1, 1, 1, 1, 1 ]




tecgraf = Iup.Image(32,32,img)
tecgraf["1"] = "BGCOLOR" 
tecgraf["2"] = "079 086 099"
tecgraf["3"] = "040 045 053"
tecgraf["4"] = "104 113 129"
tecgraf["5"] = "136 147 170"
tecgraf["6"] = "155 164 179"
tecgraf["7"] = "121 136 167"
tecgraf["8"] = "239 239 243"
tecgraf["9"] = "176 190 214"
tecgraf["10"] = "127 133 143"
tecgraf["11"] = "207 209 214"
tecgraf["12"] = "247 255 255"
tecgraf["13"] = "244 247 249"
tecgraf["14"] = "212 217 225"
tecgraf["15"] = "215 226 241"
tecgraf["16"] = "231 237 245"
  
dg = Iup.Dialog(Iup.Label("Tray example"))      
dg.title = "Tray"
dg.tray = "YES"
dg.traytip = "This is a tip at tray"
dg.trayimage = tecgraf
dg.Show()

action1 = lambda do |ih|
  dg.Show()
end

action2 = lambda do |ih|
  dg.tray = "NO" 
  dg.Hide()
  Iup::CLOSE
end

trayclick_cb = lambda do |ih, b, press, dclick|
  if b == 1 && press!=0  
    item_show = Iup.Item(:title=>"Show",:action=>action1)
    item_exit = Iup.Item(:title=>"Exit",:action=>action2)
    menu = Iup.Menu([item_show, item_exit])
    menu.Popup(Iup::MOUSEPOS, Iup::MOUSEPOS)
  end
  Iup::DEFAULT
end

dg.hidetaskbar = "YES"
dg.trayclick_cb = trayclick_cb

Iup.MainLoop() 

